let ZX_BROWING = 'zxwx_20200424_browing'
export const setbrowing = function (n, bool) {
    let getbrow = getbrowing()
    if (bool) {
        console.log(getbrow)
        for (let i = 0; i < getbrow.length; i++) {
            if (n == getbrow[i].bdid) {
                getbrow.splice(getbrow.indexOf(getbrow[i]), 1)
                console.log(getbrow)
            }
        }
        localStorage.setItem(ZX_BROWING, JSON.stringify(getbrow))
        return
    }
    console.log(n)
    getbrow.unshift(n)
    if (getbrow.length > 50) {
        getbrow.splice(0, 49)
    }
    localStorage.setItem(ZX_BROWING, JSON.stringify(getbrow))
}
export const getbrowing = function () {
    return JSON.parse(localStorage.getItem(ZX_BROWING)) || []
}

export const timestampToTime = (timestamp) => {
    let date = new Date(timestamp);
    let Y = date.getFullYear() + '-';
    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
   let DY= getdays(date)
    return Y + M + D+DY
}
const getdays = (date) => {
    var week;
    if(date.getDay() == 0) week = "星期日"
    if(date.getDay() == 1) week = "星期一"
    if(date.getDay() == 2) week = "星期二"
    if(date.getDay() == 3) week = "星期三"
    if(date.getDay() == 4) week = "星期四"
    if(date.getDay() == 5) week = "星期五"
    if(date.getDay() == 6) week = "星期六"
    return week;
}
export const timems = (timesamp) => {
    let date = new Date(timesamp);
    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
    return h + m
}